#include <ClanLib-2.0/ClanLib/display.h>
#include <ClanLib-2.0/ClanLib/sound.h>
#include <ClanLib-2.0/ClanLib/gl.h>

#include "main.h"
#include "world.h"


class InitCode
{
public:
	static int main(const std::vector<CL_String> &args)
	{
		CL_SetupCore s_core;
		CL_SetupDisplay s_display;
		CL_SetupGL s_gl;
		CL_SetupSound s_sound;

		App app;
		int ret = app.main(args);

		return ret;
	}
};

CL_ClanApplication app(&InitCode::main);

int App::main(const std::vector<CL_String> &args)
{
	try
	{
		CL_DisplayWindowDescription desc;
		desc.set_title("FNF is Not Fallout");
		desc.set_size(CL_Size(1024, 768), true); //DEBUGIT

		CL_DisplayWindow window(desc);

		CL_GraphicContext gc = window.get_gc();

		CL_SoundOutput output(44100);

		//Create game world
		World world(window);
	}
	catch (CL_Exception &exception)
	{
		CL_Console::write_line("Exception caught:");
		CL_Console::write_line(exception.message);

		std::vector<CL_String> stacktrace = exception.get_stack_trace();
		int size = stacktrace.size();
		if (size > 0)
		{
			CL_Console::write_line("Stack Trace:");
			for (int cnt = 0; cnt < size; cnt++)
				CL_Console::write_line(stacktrace[cnt]);
		}
	}

}
